import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '所属项目',
    align: "center",
    dataIndex: 'projectId_dictText'
  },
  {
    title: '使用人',
    align: "center",
    dataIndex: 'userId_dictText'
  },
  {
    title: '设备型号',
    align: "center",
    dataIndex: 'deviceId_dictText'
  },
  {
    title: '设备SN码',
    align: "center",
    dataIndex: 'deviceSn'
  },
  {
    title: '领用日期',
    align: "center",
    dataIndex: 'useDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '归还日期',
    align: "center",
    dataIndex: 'returnDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '使用状态',
    align: "center",
    dataIndex: 'useStatus_dictText'
  },
  {
    title: '描述',
    align: "center",
    dataIndex: 'description'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "所属项目",
    field: 'projectId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_project,project_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "使用人",
    field: 'userId',
    component: 'JSelectUserByDept',
    //colProps: {span: 6},
  },
  {
    label: "设备型号",
    field: 'deviceId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "device_type"
    },
    //colProps: {span: 6},
  },
  {
    label: "设备SN码",
    field: 'deviceSn',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "领用日期",
    field: 'useDate',
    component: 'DatePicker',
    //colProps: {span: 6},
  },
  {
    label: "使用状态",
    field: 'useStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "use_status"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '所属项目',
    field: 'projectId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入所属项目!'},
             ];
    },
  },
  {
    label: '使用人',
    field: 'userId',
    component: 'JSelectUserByDept',
    componentProps:{
      labelKey: 'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入使用人!'},
             ];
    },
  },
  {
    label: '设备型号',
    field: 'deviceId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "device_type"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入设备型号!'},
             ];
    },
  },
  {
    label: '设备SN码',
    field: 'deviceSn',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入设备SN码!'},
             ];
    },
  },
  {
    label: '领用日期',
    field: 'useDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入领用日期!'},
             ];
    },
  },
  {
    label: '归还日期',
    field: 'returnDate',
    component: 'DatePicker',
  },
  {
    label: '使用状态',
    field: 'useStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "use_status"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入使用状态!'},
             ];
    },
  },
  {
    label: '描述',
    field: 'description',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
